﻿using System;
using System.Collections.Generic;
using System.Linq;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace WorldOnFire
{
    public class CPlatformState : ABCState
    {
        // General data
        private CObjectManager m_ObjectManager;

        public CObjectManager GetObjectManager()
        { return m_ObjectManager; }

        // Object update speed
        private float m_fUpdateSpeed;

        // Accessors
        public void SetUpdateSpeed(float _fUpdateSpeed)
        { m_fUpdateSpeed = _fUpdateSpeed; }

        public override void Initialize()
        {
            // Create object manager
            m_ObjectManager = new CObjectManager();

            // Set game state pointers to platform state
            CSkirmishState.SetPlatformState(this);

            // Set object pointers
            ABCObject.SetContentManager(s_ContentManager);
            ABCObject.SetObjectManager(m_ObjectManager);
            ABCObject.SetRenderingManager(s_RenderingManager);
            CBuildable.SetObjectManager(m_ObjectManager);

            // Initialize object manager
            m_ObjectManager.Initialize(s_RenderingManager);
        }

        public override void Shutdown()
        {

        }

        public override void Update(float _fDeltaTime)
        {
            // Apply update multiplier
            _fDeltaTime *= m_fUpdateSpeed;

            // Update objects
            m_ObjectManager.Update(_fDeltaTime);
        }

        public override void Render()
        {
            // Render game objects
            s_RenderingManager.RenderObjects();
        }

        public override void HandleEvent(ABCEvent _Event)
        {

        }
    }
}
